<template>
  <div>
    <el-table
      :data="tableData"
      border
      style="width: 100%">
      <el-table-column
        prop="name"
        label="名称"
        width="180">
      </el-table-column>
      <el-table-column
        prop="phone"
        label="电话"
        width="180"
      >
      </el-table-column>
      <el-table-column
        prop="email"
        label="邮箱"
        width="180"
      >
      </el-table-column>
      <el-table-column
        prop="address"
        label="地址"
        width="180"
      >
      </el-table-column>
      <el-table-column
        prop="createTime"
        label="出生日期"
        width="180"
      >
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small">删除</el-button>
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      align="right"
      background
      layout="prev, pager, next"
      :total="1000">
    </el-pagination>
  </div>
</template>

<script>
  //导入axios来发送Ajax请求
  export default {
    name: 'etable',
    data () { //导出数据就可以在html中通过{{}}
      return {//对象
        tableData:[]
      }
    },
    methods:{
      getDepartments(){
        //发请求获取数据
        let param = {"currentPage":1,"pageSize":5};
        this.$http.post("/user/list",param)
          .then(result=>{ //200
            console.log(result.data)
            this.tableData =result.data.data;
          })
          .catch(result=>{//报错 500 404
            console.log(result)
          })
      }
    },
    mounted(){
      this.getDepartments();
    }
  }
</script>

